package backend.project.gym_management.service.impl;

import backend.project.gym_management.mapper.AliPayMapper;
import backend.project.gym_management.service.AliPayService;
import backend.project.gym_management.pojo.entity.PayOrder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AliPayServiceImp implements AliPayService {
    @Autowired
    AliPayMapper aliPayMapper;

    @Override
    public PayOrder selectOrder(Long oid) {
        log.debug("开始处理【查询订单】业务，参数：{}", oid);
        return aliPayMapper.selectOrder(oid);
    }

    @Override
    public boolean updateOrder(PayOrder payOrder) {
        log.debug("开始处理【更新订单】业务，参数：{}", payOrder);
        return aliPayMapper.updateOrder(payOrder) > 0;
    }

    @Override
    public PayOrder checkExistingOrder(Long uid, Long cid) {
        return aliPayMapper.checkExistingOrder(uid, cid);
    }

    @Override
    public PayOrder selectOrderByUserAndCourse(Long uid, Long cid) {
        return aliPayMapper.selectOrderByUserAndCourse(uid, cid);
    }

    @Override
    public boolean hadCourse(Long uid, Long cid) {
        return aliPayMapper.hadCourse(uid, cid) > 0;
    }

    @Override
    public String getUnameByUid(Long uid) {
        String uname = aliPayMapper.getUnameByUid(uid);
        log.debug("查询用户名成功，结果：{}", uname);
        return uname;
    }
}
